//
//  main.swift
//  2.将protocol方法声明为mutating
//
//  Created by 左忠飞 on 2021/8/11.
//

import Foundation

protocol Vehicle {
    var numberOfWheels:Int{get}
    var color:String{get set}
    
    //将协议的方法声明为mutating,可以在方法中修改结构体成员的值,否则不能修改
    mutating func changeColor()
}

struct MyCar:Vehicle {
    let numberOfWheels: Int = 4
    var color: String = "blue"
    
    mutating func changeColor() {
        color = "red"
    }
}
